﻿/*-----------------------------------------------------------------------
 * <copyright file="ProductionRelatedPage.xaml.cs" company="O-RID">
 *     Copyright (c)2010 O-RID Co.,Ltd.
 * </copyright>
 * <author>Zhang jun</author>
 * <summary>
 *             录入权限查询
 * 
 *          作成日：07/27/2010
 *                  10/09/2010 将原来的OPRolesQueryControl页（OPRolesQueryControl-Hide）代码隐藏 by Zhang jun
 * </summary>
 *----------------------------------------------------------------------- 
 */

namespace Orid.Management.Statistics.OperatorUnitMangement.TheOthersRelated.OPRolesQuery
{
    using System.Windows.Controls;
    using System.Windows.Navigation;
    using System.Windows;

    public partial class OPRolesQueryPage : Page
    {
        bool isExpanded = false;

        //10/09/2010 原OPRolesQueryControl代码隐藏  ↓ by Zhang jun
        //OPRolesQueryControl oPRolescontainer = null;

        OPRolesQueryControlNew oPRolescontainer = null;

        public OPRolesQueryPage()
        {
            InitializeComponent();
        }

        // 当用户导航到此页面时执行。
        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            #region 代码隐藏
            //10/09/2010 原OPRolesQueryControl代码隐藏  ↓ by Zhang jun
            //oPRolescontainer = new OPRolesQueryControl();

            //this.bOPRolesPage.Child = oPRolescontainer;

            //oPRolescontainer.accoridon.SelectedItemsChanged -= new System.Collections.Specialized.NotifyCollectionChangedEventHandler(accoridon_SelectedItemsChanged);
            //oPRolescontainer.accoridon.SelectedItemsChanged += new System.Collections.Specialized.NotifyCollectionChangedEventHandler(accoridon_SelectedItemsChanged);
            //10/09/2010 原OPRolesQueryControl代码隐藏  ↑ by Zhang jun
            #endregion 代码隐藏

            #region 
            oPRolescontainer = new OPRolesQueryControlNew();

            this.bOPRolesPage.Child = oPRolescontainer;

            oPRolescontainer.accoridon.SelectedItemsChanged -= new System.Collections.Specialized.NotifyCollectionChangedEventHandler(accoridon_SelectedItemsChanged);
            oPRolescontainer.accoridon.SelectedItemsChanged += new System.Collections.Specialized.NotifyCollectionChangedEventHandler(accoridon_SelectedItemsChanged);
            #endregion

            IsExpanded();
            
        }

        /// <summary>
        /// accoridon 选择ITME事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        void accoridon_SelectedItemsChanged(object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e)
        {
            IsExpanded();
        }

        /// <summary>
        /// 判断 accoridon 收缩或展开时，DATAGRID的位置
        /// </summary>
        void IsExpanded()
        {
            #region 代码隐藏
            //10/09/2010 原OPRolesQueryControl代码隐藏  ↓ by Zhang jun
            //if (isExpanded == true)
            //{
            //    oPRolescontainer.rowAccordionHeight.Height = new GridLength(65);
            //}
            //else//
            //{
            //    oPRolescontainer.rowAccordionHeight.Height = new GridLength(25);
            //}
            //10/09/2010 原OPRolesQueryControl代码隐藏  ↑ by Zhang jun
            #endregion 代码隐藏

            #region
            if (isExpanded == true)
            {
                this.oPRolescontainer.rowAccordionHeight.Height = new GridLength(65);
            }
            else//
            {
                this.oPRolescontainer.rowAccordionHeight.Height = new GridLength(25);
            }
            #endregion

            this.isExpanded = !this.isExpanded;
        }


    }
}
